import json
from flask import Blueprint, jsonify

reports_bp = Blueprint('reports', __name__)

@reports_bp.route('/orders', methods=['GET'])
def get_order_reports():
    data={
            "order_count": {
            "today_new": 120,
            "total_orders": 56789,
            "historical_trend": [
                {"date": "2024-12-01", "amount": 12500},
                {"date": "2024-12-02", "amount": 13500},
                {"date": "2024-12-03", "amount": 14000},
                {"date": "2024-12-04", "amount": 15000},
                {"date": "2024-12-05", "amount": 15500},
                {"date": "2024-12-06", "amount": 14200},
                {"date": "2024-12-07", "amount": 14700}
            ]
            }
        }

    return json.dumps({"status": 200,"message": f"get_order_reports","data": data},sort_keys=False)

@reports_bp.route('/transaction', methods=['GET'])
def get_logistics_reports():
    data={
            "transaction_amount": {
                "today": 15800,
                "total": 32456789,
                "historical_trend": [
                    {"date": "2024-12-01", "amount": 12500.5},
                    {"date": "2024-12-02", "amount": 13500.3},
                    {"date": "2024-12-03", "amount": 14000.8},
                    {"date": "2024-12-04", "amount": 15000.2},
                    {"date": "2024-12-05", "amount": 15500.9},
                    {"date": "2024-12-06", "amount": 14200.0},
                    {"date": "2024-12-07", "amount": 14700.5}
                ]
            }
        }
    return json.dumps({"status": 200,"message": f"get_transaction_reports","data": data},sort_keys=False)

@reports_bp.route('/warehouses', methods=['GET'])
def get_warehouse_reports():
    data={
        "inventory_overview": {
            "total_items": 25680,
            "utilization_rate": 78.5
        },
        "out_of_stock_items": [
            {
            "item_name": "Mouse",
            "out_of_stock_count": 5
            },
            {
            "item_name": "Keyboard",
            "out_of_stock_count": 7
            }
        ],
        "daily_flow": {
            "inbound": 320,
            "outbound": 280
        }
    }
    return json.dumps({"status": 200,"message": f"get_warehouse_reports","data": data},sort_keys=False)

@reports_bp.route('/products', methods=['GET'])
def get_product_reports():
    data={
        "total_products": 1245,
        "top_selling_products": [
            {
            "name": "Wireless Earbuds",
            "sales": 320
            },
            {
            "name": "Bluetooth Speaker",
            "sales": 250
            },
            {
            "name": "Smart Watch",
            "sales": 200
            }
        ],
        "page_views": {
            "today": 5000,
            "historical_trend": [
            {
                "date": "2024-12-01",
                "views": 4700
            },
            {
                "date": "2024-12-02",
                "views": 4800
            },
            {
                "date": "2024-12-03",
                "views": 4900
            },
            {
                "date": "2024-12-04",
                "views": 5000
            },
            {
                "date": "2024-12-05",
                "views": 5100
            },
            {
                "date": "2024-12-06",
                "views": 4950
            },
            {
                "date": "2024-12-07",
                "views": 5050
            }
            ]
        }
    }
    
    return json.dumps({"status": 200,"message": f"get_product_reports","data": data},sort_keys=False)
